package com.cykj.page04.servlet;


import com.alibaba.fastjson2.JSON;
import com.cykj.page04.dto.ResponseDTO;
import com.cykj.page04.net.MyHttpRequest;
import com.cykj.page04.net.MyHttpResponse;
import com.cykj.page04.service.impl.UserServiceImpl;


/**
 * @BelongsProject: HandTomcat
 * @BelongsPackage: com.cykj.page03
 * @Author: WWJ
 * @CreateTime: 2025-06-18 13:17
 * @Description: 对登录的处理  简单的功能
 * @Version: 1.0
 */
public class LoginServlet extends BaseServlet {

    @Override
    public void doGet(MyHttpRequest httpRequest, MyHttpResponse httpResponse) {
            doPost(httpRequest, httpResponse);
    }

    @Override
    public void doPost(MyHttpRequest httpRequest, MyHttpResponse httpResponse) {
        String acc= httpRequest.getRequestParamToKey("account");
        String pwd = httpRequest.getRequestParamToKey("password");
        UserServiceImpl userService = new UserServiceImpl();
        ResponseDTO dto = userService.login(acc, pwd);
        httpResponse.write( JSON.toJSONBytes(dto));
    }
}


